package com.hottop.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hottop.common.annotation.Log;
import com.hottop.common.core.controller.BaseController;
import com.hottop.common.core.domain.AjaxResult;
import com.hottop.common.enums.BusinessType;
import com.hottop.system.domain.SysWeb;
import com.hottop.system.service.ISysWebService;
import com.hottop.common.utils.poi.ExcelUtil;
import com.hottop.common.core.page.TableDataInfo;

/**
 * 热搜平台信息Controller
 * 
 * @author ruoyi
 * @date 2022-02-19
 */
@RestController
@RequestMapping("/system/web")
public class SysWebController extends BaseController
{
    @Autowired
    private ISysWebService sysWebService;

    /**
     * 查询热搜平台信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:web:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysWeb sysWeb)
    {
        startPage();
        List<SysWeb> list = sysWebService.selectSysWebList(sysWeb);
        return getDataTable(list);
    }

    /**
     * 导出热搜平台信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:web:export')")
    @Log(title = "热搜平台信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysWeb sysWeb)
    {
        List<SysWeb> list = sysWebService.selectSysWebList(sysWeb);
        ExcelUtil<SysWeb> util = new ExcelUtil<SysWeb>(SysWeb.class);
        util.exportExcel(response, list, "热搜平台信息数据");
    }

    /**
     * 获取热搜平台信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:web:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sysWebService.selectSysWebById(id));
    }

    /**
     * 新增热搜平台信息
     */
    @PreAuthorize("@ss.hasPermi('system:web:add')")
    @Log(title = "热搜平台信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysWeb sysWeb)
    {
        return toAjax(sysWebService.insertSysWeb(sysWeb));
    }

    /**
     * 修改热搜平台信息
     */
    @PreAuthorize("@ss.hasPermi('system:web:edit')")
    @Log(title = "热搜平台信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysWeb sysWeb)
    {
        return toAjax(sysWebService.updateSysWeb(sysWeb));
    }

    /**
     * 删除热搜平台信息
     */
    @PreAuthorize("@ss.hasPermi('system:web:remove')")
    @Log(title = "热搜平台信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysWebService.deleteSysWebByIds(ids));
    }
}
